<template>
    <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="原密码">
            <el-input v-model="form.oldPwd" type="password" />
        </el-form-item>
        <el-form-item label="新密码">
            <el-input v-model="form.password" type="password" />
        </el-form-item>
        <el-form-item label="确认密码">
            <el-input v-model="form.twicePwd" type="password" />
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="onSubmit">立即修改</el-button>
        </el-form-item>
    </el-form>
</template>
<script>
import uploadImg from '@/components/uploadImg'
import { modifyPwd } from '@/api'
export default {
    components: {
        uploadImg
    },
    data() {
        return {
            form: {}
        }
    },
    methods: {
        async onSubmit() {
            let res = await modifyPwd(this.form)
            this.$message.success(res.message)
            setTimeout(_ => {
                this.$store.commit('setUserInfo', {})
                this.$store.commit('setRouters', [])
                localStorage.clear()
                this.$router.push('/login')
            }, 1000)
        }
    }
}
</script>